package com.talent.service.iot.mqtt.model.variable;

import io.netty.handler.codec.mqtt.MqttConnectReturnCode;

/**
 * @ClassName：TlMqttVariableHead
 * @Author: hszhou
 * @Date: 2024/11/25 11:13
 * @Description:
 * mqtt的请求可变头
 * 协议名称 协议 连接标识 保持连接
 */
public class TlMqttConnackVariableHead{

    /**会话是否保存*/
    private int currentSession;

    /**连接返回码*/
    private int code;

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public int getCurrentSession() {
        return currentSession;
    }

    public void setCurrentSession(int currentSession) {
        this.currentSession = currentSession;
    }


    public static TlMqttConnackVariableHead of(int currentSession, MqttConnectReturnCode returnCode){
        TlMqttConnackVariableHead variableHead = new TlMqttConnackVariableHead();
        variableHead.setCurrentSession(currentSession);
        variableHead.setCode(returnCode.byteValue());
        return variableHead;
    }
    @Override
    public String toString() {
        return "TlMqttConnackVariableHead{" +
                "currentSession=" + currentSession +
                ", code=" + code +
                '}';
    }
}
